package com.hub.grpc.server;

import com.hub.grpc.server.annotation.GrpcService;
import com.hub.grpc.server.config.ServiceManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;
import java.util.Map;

@SpringBootApplication
public class GrpcServeApplication {

    public static void main(String[] args) throws IOException, InterruptedException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(GrpcServeApplication.class, args);

        Map<String, Object> grpcServers = applicationContext.getBeansWithAnnotation(GrpcService.class);
        ServiceManager serviceManager = applicationContext.getBean(ServiceManager.class);
        serviceManager.loadService(grpcServers);
    }
}
